# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libmodplug

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.8.8.5
pkgrel=2
pkgdesc="A MOD playing library (mingw-w64)"
arch=('any')
url="http://modplug-xmms.sourceforge.net/"
license=("custom")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('strip' 'staticlibs')
source=("http://downloads.sourceforge.net/modplug-xmms/${_realname}-${pkgver}.tar.gz"
        0001-stdafx-mingw-w64.mingw.patch
        0002-fix-pkgconfig-file.patch)
md5sums=('5f30241db109d647781b784e62ddfaa1'
         '0853de6307501e2f2e9c7aae4b6ca226'
         '84765aa95e603fd206f0e1d7f142aeaf')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-stdafx-mingw-w64.mingw.patch"
  patch -p1 -i "${srcdir}/0002-fix-pkgconfig-file.patch"
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  # Install license
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
